package com.djp.computerServer.controller;

import com.djp.computerServer.bean.User;
import com.djp.computerServer.service.UserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController extends BaseController<UserService>{
    @RequestMapping("/login")
    @ResponseBody
    public Map login(@RequestBody User user){
        return buildMap("登录", service.getOne(user));
    }

    @RequestMapping("/register")
    @ResponseBody
    public Map register(@RequestBody User user){
        return buildMap("注册", service.add(user));
    }

    @RequestMapping("/getOne")
    @ResponseBody
    public Map getOne(@RequestBody User user) {
        return buildMap("获取一条用户信息", service.getOne(user));
    }

    @RequestMapping("/getAll")
    @ResponseBody
    public Map getAll() {
        return buildMap("获取全部用户信息", service.getAll());
    }
}
